define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'usermoneylog/index' + location.search,
                    add_url: 'usermoneylog/add',
                    edit_url: 'usermoneylog/edit',
                    del_url: 'usermoneylog/del',
                    multi_url: 'usermoneylog/multi',
                    table: 'user_money_log',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'userinfo.username', title: '用户名称',operate:"LIKE"},
                        {field: 'userinfo.mobile', title: '手机号',operate:"LIKE"},
                        {field: 'oper_type', title: __('Oper_type'), searchList: {"1":__('Oper_type 1'),"2":__('Oper_type 2')}, formatter: Table.api.formatter.normal},
                        {field: 'user_level_type', title:'会员类型',searchList: Config.userlevellabellist,operate: 'FIND_IN_SET', formatter: Table.api.formatter.label},
                        {field: 'level_day', title: __('Level_day'),operate:false},
                        {field: 'xieyi_num', title: __('Xieyi_num'),operate:false},
                        {field: 'money', title: __('Money'),operate:false},
                        {field: 'after_level_day', title: __('After_level_day'),operate:false},
                        {field: 'after_xieyi_num', title: __('After_xieyi_num'),operate:false},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'admin.username', title: __('Admin_id'),operate:false},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });
         $(".search input").attr('placeholder','请输入搜索内容');
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
